//
// Created by madison on 2022/6/22.
//

#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

class Solution {
public:
    int singleNumber(vector<int> &nums) {
        int ret = 0;
        for (auto e: nums) ret ^= e;
        return ret;
    }

    int singleNumber1(vector<int> &nums) {
        unordered_set<int> s;
        for (int num: nums) {
            s.insert(num);
            cout << *s.find(num) << endl;
            cout << *s.find(num) << endl;
            cout << *s.end() << endl;
            if (s.find(num) == s.end()) {
                s.erase(s.find(num));
            }

        }
        return *s.begin();
    }
};

int main() {
    Solution solution;
    vector<int> nums = {4, 1, 2, 1, 2};
    printf("%d", solution.singleNumber(nums));
    return 0;
}